namespace FormsAnywhere.UIProcessDesigner
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections.Specialized;
    using Microsoft.VisualStudio.Modeling.Validation;

    [ValidationState(ValidationState.Enabled)]
    public partial class UIProcessForm
    {
        // Validation methods for FormsAnywhereForm go here.

        // This attribute identifies the method ValidateNameValue 
        // to the validation framework.
        [ValidationMethod
         ( // These values select which events cause the method to be invoked.
            ValidationCategories.Open |
             ValidationCategories.Save |
              ValidationCategories.Menu
         )
        ]
        // This method is applied to each instance of the 
        // type in a model. 
        private void ValidateNameValue(ValidationContext context)
        {
            if(String.IsNullOrEmpty(this.Name))
            {
                context.LogError(
                    // Description
                             "A value is required for the element Name",
                    // Unique code for this error
                             "FAW001FormsAnywhereFormError",
                    // Objects to select when user double-clicks error
                             this);
            }
        }

        // This attribute identifies the method ValidateVersionValue 
        // to the validation framework.
        [ValidationMethod
         ( // These values select which events cause the method to be invoked.
             ValidationCategories.Open |
             ValidationCategories.Save |
              ValidationCategories.Menu
         )
        ]
        // This method is applied to each instance of the 
        // type in a model. 
        private void ValidateVersionValue(ValidationContext context)
        {
            if (String.IsNullOrEmpty(this.Version))
            {
                context.LogError(
                    // Description
                             "A value is required for the element Version",
                    // Unique code for this error
                             "FAW002FormsAnywhereFormError",
                    // Objects to select when user double-clicks error
                             this);
            }
        }
    }
}
